<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${article.title}">文章标题</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            padding-top: 60px;
        }
        .article-content img {
            max-width: 100%;
            height: auto;
        }
    </style>
</head>
<body>

<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
    <div class="container">
        <a class="navbar-brand" href="/">沐硕博客</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav ms-auto">
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/}">首页</a>
                </li>
                <li class="nav-item" th:if="${user != null}">
                    <a class="nav-link" th:href="@{/user/center}">个人中心</a>
                </li>
                <li class="nav-item" th:if="${user == null}">
                    <a class="nav-link" th:href="@{/login}">登录</a>
                </li>
                <li class="nav-item" th:if="${user != null}">
                    <a class="nav-link" th:href="@{/logout}">退出</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<!-- 文章内容区域 -->
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-10">
            <div class="card shadow-sm">
                <div class="card-body">
                    <!-- 文章标题 -->
                    <h2 class="card-title mb-4" th:text="${article.title}">文章标题</h2>

                    <!-- 作者信息 -->
                    <div class="mb-3 text-muted">
                        <small>作者：<span th:text="${article.userId}">匿名用户</span> |
                            分类：<span th:text="${article.categoryId}">未分类</span> |
                            发布时间<span th:text="${article.createTime}">未知时间</span>
                        </small>
                    </div>

                    <!-- 文章正文 -->
                    <div class="article-content fs-5" th:utext="${article.content}">
                        这里是文章的正文内容...
                    </div>

                    <!-- 点赞和收藏按钮（可选） -->
                    <hr class="my-4">
                    <div class="d-flex justify-content-between">
                        <button class="btn btn-outline-primary">
                            <i class="bi bi-hand-thumbs-up"></i> 赞 (<span>0</span>)
                        </button>
                        <button class="btn btn-outline-secondary">
                            <i class="bi bi-bookmark"></i> 收藏
                        </button>
                    </div>
                </div>
            </div>

            <!-- 评论区 -->
            <div class="mt-5">
                <h4>评论</h4>
                <div class="list-group mb-4" th:each="comment : ${comments}">
                    <div class="list-group-item">
                        <div class="d-flex justify-content-between">
                            <h6 th:text="${comment.userId}">用户名</h6>
                            <small th:text="${article.createTime}">时间</small>
                        </div>
                        <p class="mt-2" th:text="${comment.content}">评论内容...</p>
                    </div>
                </div>
            </div>

          <form th:action="@{/api/comments/form}" method="post">
    <input type="hidden" name="articleId" th:value="${article.articleId}">
    <div class="mb-3">
        <label for="commentContent" class="form-label">发表评论</label>
        <textarea class="form-control" id="commentContent" name="content" rows="3" required></textarea>
    </div>
    <button type="submit" class="btn btn-primary">提交评论</button>
</form>

        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
